package com.mz.ozy.mvp.model;


import android.app.Activity;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * @author
 * @date 2018/7/25
 * @description
 */
public class PrivateDetailModel {

    public Observable<ResponseBody> obtainShopDetailInfo(Activity activity, String goodsId) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", goodsId);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10088, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    /**
     * 获取商品规格
     *
     * @param activity
     * @param goodsId
     * @return
     */
    public Observable<ResponseBody> obtainSpecList(Activity activity, String goodsId) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", goodsId);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10114, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    /**
     * 商品规格修改查询
     *
     * @param activity
     * @param cid
     * @param MenuId
     * @param key
     * @return
     */
    public Observable<ResponseBody> updateShopSpec(Activity activity, String cid, String MenuId, String key) {
        Map<String, String> maps = new HashMap<>();
//        maps.put("transCode",Constants.TransCode.SpecificationQueryV1);
//        maps.put("cid",cid);
//        maps.put("key",key);
//        maps.put("MenuId",MenuId);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10013, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> onJoinCar(Activity activity, String goodsID, String ggId, String buyNumber) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", goodsID);
        maps.put("gId", ggId);
        maps.put("num", buyNumber);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10115, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> onGoodsFollow(Activity activity, String gid) {
        Map<String, String> maps = new HashMap<>();
        maps.put("cid", gid);
        maps.put("type", "0");
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10162, JsonUtils.requestJsonDate(maps), Constants.tokenId);

    }

    public Observable<ResponseBody> onGoodsCancleFollow(Activity activity, String gid) {
        Map<String, String> maps = new HashMap<>();
//        maps.put("transCode", Constants.TransCode.GoodsCancelFollowV1);
//        maps.put("pid", gid);
//        maps.put("t", SharePreferencesData.getSharePreferencesData(activity, Constants.PREE.TOKEN_ID));
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10013, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }

    public Observable<ResponseBody> onBuy(Activity activity, String goodsId, String gid) {
        Map<String, String> maps = new HashMap<>();
        maps.put("id", goodsId);
        maps.put("attribute_id", gid);
        return RetrofitUtils.getApiService(activity).post(Constants.TransCode.TransCode10089, JsonUtils.requestJsonDate(maps), Constants.tokenId);
    }
}
